package com.guiji.quartz.task;

import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import com.guiji.quartz.domain.IFengNews;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.model.OOSpider;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{
	private static final Logger log = LoggerFactory.getLogger(PeopleNewsTask.class);
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        Console.log(StrUtil.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        Console.log("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
		Long startTime = System.currentTimeMillis();
		OOSpider.create(Site.me().setSleepTime(1000)
			,(o, task) -> {}
			, IFengNews.class)
			.addUrl("https://mil.ifeng.com/")
			.addUrl("https://ent.ifeng.com/")
			.addUrl("https://tech.ifeng.com/")
			.addUrl("https://finance.ifeng.com/")
			.thread(20).run();
		log.info("FenghuangJunshi-end-:{}",System.currentTimeMillis()-startTime);
    }
}
